<!DOCTYPE html>
<html>
<head>
    <title>房源签认主界面</title>
    <#include "../common/common.ftl"/>
</head>
<body>
<div class="layui-fluid">
    <form class="layui-form">
        <div class="layui-card">
            <div class="layui-card-header">一、被征收人基本信息
               <#-- <button type="button" class="layui-btn jmdf-btn-view viewChoose"><i
                            class="layui-icon layui-icon-rate-solid" style="position:static;"></i>查看费用明细
                </button>-->
<#--
                <button type="button" class="layui-btn setIsJiSuan">享有优惠扩购面积管理</button>
-->
                <button type="button" class="layui-btn setArea">选房后合并</button>
            </div>
            <div class="layui-card-body">
                <div class="layui-form-item">
                    <div class="layui-col-xs4">
                        征收项目：${(contract.zsProject.projectName)!}
                    </div>
                    <div class="layui-col-xs4">
                        协议编号：${(contract.contractCode)!}
                    </div>
                    <div class="layui-col-xs4">
                        选房号：${(contract.chooseHouseNum)!}
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-xs4">
                        被征收人：${(contract.name)!}
                    </div>
                    <div class="layui-col-xs4">
                        身份证号：${(contract.idCard)!}
                    </div>
                    <div class="layui-col-xs4">
                        选择产权调换面积：【<span class="jmdf-color-green">${(contract.ysHouseAreaTotal)!}</span>】㎡
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-xs4">
                        住改商间数：${(contract.zgsHouseAzNum)!}<span class="jmdf-color-red">间</span>
                    </div>
                    <div class="layui-col-xs4">
                        商业店面间数：${(contract.syDmAzNum)!}<span class="jmdf-color-red">间</span>
                    </div>
                    <div class="layui-col-xs4">
                        安置方式：<span class="jmdf-color-red">${(contract.azType)!}</span>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-xs4">
                        原产权面积：${(contract.ysHouseAreaTotal)!}
                    </div>
                    <div class="layui-col-xs4">
                        合并产权调换面积：【<span class="jmdf-color-orange">${(contract.adjustAreaTotal)!}</span>】㎡
                    </div>
                    <div class="layui-col-xs4">
                        实际产权调换面积：【<span class="jmdf-color-red">${(contract.limitHouseAreaTotal)!}</span>】㎡
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-xs4">
                        图纸编号：${(contract.drawingCode)!}
                    </div>
                    <div class="layui-col-xs4">
                        析产份数：【<span class="jmdf-color-orange">${(contract.xcOrJcNum)!}</span>】
                    </div>
                    <div class="layui-col-xs4">
                        3800优惠面积：【<span class="jmdf-color-red">${(overArea)!}</span>】㎡
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-xs12">
                        所在路段：${(contract.zqSzLd)!}
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-xs4">
                        住改商需安置间数：${(contract.zgsHouseAzNum)!}
                    </div>
                    <div class="layui-col-xs4">
                        商业店面需安置间数：${(contract.syDmAzNum)!}
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-xs4">
                        住改商需安置面积：【<span class="jmdf-color-orange">${(contract.zgsHouseAzArea)!}</span>】
                    </div>
                    <div class="layui-col-xs4">
                        商业店面需安置面积：【<span class="jmdf-color-orange">${(contract.syDmAzArea)!}</span>】
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-xs4">
                        商业二层需安置面积：【<span class="jmdf-color-orange">${(contract.syTwoFloorAzArea)!}</span>】
                    </div>
                    <div class="layui-col-xs4">
                        商业写字楼需安置面积：【<span class="jmdf-color-orange">${(contract.syXzlAzArea)!}</span>】
                    </div>
                    <div class="layui-col-xs4">
                        商业商场需安置面积：【<span class="jmdf-color-orange">${(contract.syScAzArea)!}</span>】
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-card">
            <div class="layui-card-header">二、预定户型</div>
            <div class="layui-card-body">
                <div class="layui-form-item">
                    <#if contract.carLotYxYdNum?? && contract.carLotYxYdNum gt 0>
                        <div class="layui-col-xs2">
                            预定车位：${(contract.carLotYxYdNum)!}<span class="jmdf-color-red">个</span>
                        </div>
                    </#if>
                    <#if contract.carLotYxZhNum?? && contract.carLotYxZhNum gt 0>
                        <div class="layui-col-xs2">
                            置换车位：${(contract.carLotYxZhNum)!}<span class="jmdf-color-red">个</span>
                        </div>
                    </#if>
                    <#if contract.house60YxNum?? && contract.house60YxNum gt 0>
                        <div class="layui-col-xs2">
                            60型：${(contract.house60YxNum)!}<span class="jmdf-color-red">套</span>
                        </div>
                    </#if>
                    <#if contract.house80YxNum?? && contract.house80YxNum gt 0>
                        <div class="layui-col-xs2">
                            80型：${(contract.house80YxNum)!}<span class="jmdf-color-red">套</span>
                        </div>
                    </#if>
                    <#if contract.house100YxNum?? && contract.house100YxNum gt 0>
                        <div class="layui-col-xs2">
                            100型：${(contract.house100YxNum)!}<span class="jmdf-color-red">套</span>
                        </div>
                    </#if>
                    <#if contract.house120YxNum?? && contract.house120YxNum gt 0>
                        <div class="layui-col-xs2">
                            120型：${(contract.house120YxNum)!}<span class="jmdf-color-red">套</span>
                        </div>
                    </#if>
                </div>

                <div class="layui-form-item">
                    <#if contract.house140YxNum?? && contract.house140YxNum gt 0>
                        <div class="layui-col-xs2">
                            140型：${(contract.house140YxNum)!}<span class="jmdf-color-red">套</span>
                        </div>
                    </#if>
                    <#if contract.house160YxNum?? && contract.house160YxNum gt 0>
                        <div class="layui-col-xs2">
                            160型：${(contract.house160YxNum)!}<span class="jmdf-color-red">套</span>
                        </div>
                    </#if>
                    <#if contract.house180YxNum?? && contract.house180YxNum gt 0>
                        <div class="layui-col-xs2">
                            180型：${(contract.house180YxNum)!}<span class="jmdf-color-red">套</span>
                        </div>
                    </#if>
                    <#if contract.houseFsOneYxNum?? && contract.houseFsOneYxNum gt 0>
                        <div class="layui-col-xs2">
                            复式1型：${(contract.houseFsOneYxNum)!}<span class="jmdf-color-red">套</span>
                        </div>
                    </#if>
                    <#if contract.houseFsTwoYxNum?? && contract.houseFsTwoYxNum gt 0>
                        <div class="layui-col-xs2">
                            复式2型：${(contract.houseFsTwoYxNum)!}<span class="jmdf-color-red">套</span>
                        </div>
                    </#if>
                </div>
            </div>
        </div>
        <div class="layui-card">
            <div class="layui-card-header">三、请选择房源</div>
            <div class="layui-card-body">
                <div class="layui-form-item">
                    <div class="layui-col-xs12">
                        <#if (azProjectIdList?size > 0)>
                            <#list azProjectIdList as azProjectId>
                                <#assign azProject=azProjectMap[azProjectId?c]/>
                                <a class="layui-btn loadAzProject" azProjectId="${(azProject.id)!}"><i
                                            class="layui-icon layui-icon-home"></i>${(azProject.projectName)!}</a>
                            </#list>
                        </#if>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-card">
            <div class="layui-card-header">四、已选房源
                <button type="button" class="layui-btn jmdf-btn-print chooseResultPrint"><i
                            class="layui-icon layui-icon-rate-solid" style="position:static;"></i>打印房源签认表
                </button>
                <button type="button" class="layui-btn chooseHouseStatus
                    <#if contract.chooseHouseStatus == 2> layui-btn-danger</#if>" contractId="${(contract.id)!}">
                    <#if contract.chooseHouseStatus == 1>设置为已签认<#else>设置为未签认</#if>
                </button>
            </div>
        </div>
        <div class="layui-card-body" id="selectHouseInfo"></div>
</div>
<div class="layui-card">
    <div class="layui-card-header">
        五、已选车位　<#if (contract.chooseHouseStatus == 1)>
        <button type="button" class="layui-btn carLotAdd">选择车位</button></#if>
    </div>
    <div class="layui-card-body">
        <table class="layui-table" lay-filter="layFilter" id="carLotTable"></table>
    </div>
</div>
<div class="layui-card">
    <div class="layui-card-header">
        六、已选店铺　<#if (contract.chooseHouseStatus == 1)>
        <button type="button" class="layui-btn loadAzProjectShopHouse">选择店铺</button></#if>
    </div>
    <div class="layui-card-body" id="selectShopHouseInfo"></div>

</div>
</form>
</div>
<script type="text/html" id="indexTpl">
    {{d.LAY_TABLE_INDEX+1}}
</script>
<!--菜单-->
<script type="text/html" id="carLotTable_toolbar">
    <#if (contract.chooseHouseStatus == 1)>
        <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="carLotTable_delete"><i
                    class="layui-icon layui-icon-delete"></i>撤销车位</a>
    </#if>
</script>
<script src="/layui/layui.js" charset="utf-8"></script>
<script>
    layui.config({
        base: '/modules/' //静态资源所在路径
    }).use(['jquery', 'jmdf', 'form', 'table'], function () {
        var $ = layui.jquery, jmdf = layui.jmdf, form = layui.form, table = layui.table,
            parentIndex = parent.layer.getFrameIndex(window.name);

        $(".loadAzProject").click(function () {
            var obj = $(this);
            jmdf.view("housePicture?contractId=${(contract.id)!}&azProjectId=" + obj.attr("azProjectId"), "90");
            $(".loadAzProject").removeClass("layui-btn-danger");
            obj.addClass("layui-btn-danger")
        });
        $(".loadAzProjectStorageRoom").click(function () {
            var obj = $(this);
            jmdf.view("storageRoomList?type=1&contractId=${(contract.id)!}&azProjectId=" + obj.attr("azProjectId"), "90");
        });

        $(".carLotAdd").click(function () {
            jmdf.view("carLotList?contractId=${(contract.id)!}", "80");
        });
        $(".loadAzProjectShopHouse").click(function () {
            var obj = $(this);
            jmdf.view("shopHouseList?contractId=${(contract.id)!}&azProjectId=" + obj.attr("azProjectId"), "90");
        });
        form.render();

        //列项内容
        var cols = [[
            {title: "序号", toolbar: '#indexTpl', type: "numbers", fixed: 'left', align: 'center', width: 60}
            , {field: "projectName", title: "安置项目", align: 'center', width: 200}
            , {field: "carLotInfo", title: "车位信息", align: 'center'}
            , {field: "buildArea", title: "建筑面积(㎡)", align: 'center'}
            , {field: "carLotTypeStr", title: "车位类型", align: 'center'}
            , {field: "sfHgStr", title: "购买/换购", align: 'center'}
            , {field: "hgArea", title: "置换车位面积要扣除(㎡)", align: 'center'}
            , {field: "xjnMoney", title: "需缴纳(元)", align: 'center'}
            , {title: '操作', fixed: 'right', align: 'center', toolbar: '#carLotTable_toolbar', width: 200}
        ]];

        //table设置项
        var options = {
            elem: '#carLotTable' //table列表id值
            , url: "loadSelectCarLotInfo?contractId=${(contract.id)!}"
            , cols: cols
            , id: "renderId"
        };
        table.render(options);

        table.on("tool(layFilter)", function (obj) {
            var data = obj.data;///获得当前行数据
            var layEvent = obj.event;//获得lay-event对应的值
            var id = data["id"];
            if (layEvent == "carLotTable_delete") {
                layer.open({
                    title: false,
                    shade: 0.5,
                    content: "确定要撤销【" + data['carLotInfo'] + "】车位吗？",
                    btn: ['确定', '取消'],
                    closeBtn: 0,
                    btnAlign: 'c'
                    ,
                    yes: function (index) {
                        $.get("carLotDelete", {carLotId: data["id"], _time: new Date().getTime()}, function (data) {
                            if (data.code == "0001") {//成功
                                layer.msg(data.message, {anim: 0, icon: 1, time: 1000}, function () {
                                    //加载车位列表
                                    reloadSelectCarLotInfo();
                                    //房源列表需重新刷新
                                    loadSelectHouseInfo("${(contract.id)!}");
                                });
                            } else {//失败
                                layer.msg(data.message, {anim: 6, icon: 2, time: 3000});
                            }
                            layer.close(index);
                        });
                    }
                });
            }
        });

        function reloadSelectCarLotInfo() {
            table.reload("renderId", {});
        }

        //房源
        function loadSelectHouseInfo(contractId) {
            $.get("selectHouseInfo", {contractId: contractId, _time: new Date().getTime()}, function (data) {
                $("#selectHouseInfo").html(data);
            });
        }

        loadSelectHouseInfo("${(contract.id)!}");

        //店铺
        function loadSelectShopHouseInfo(contractId) {
            $.get("selectShopHouseInfo", {contractId: contractId, _time: new Date().getTime()}, function (data) {
                $("#selectShopHouseInfo").html(data);
            });

            //此处需同时加载已选房源列表展示
            loadSelectHouseInfo("${(contract.id)!}");

        }

        loadSelectShopHouseInfo("${(contract.id)!}");


        window.loadSelectHouseInfo = loadSelectHouseInfo;
        window.loadSelectShopHouseInfo = loadSelectShopHouseInfo;
        window.reloadSelectCarLotInfo = reloadSelectCarLotInfo;


        //查看计算信息
        $(".viewChoose").click(function () {
            jmdf.view("viewChoose?contractId=${(contract.id)!}", "40");
        });

        //设置剩余面积是否结算
        $(".setIsJiSuan").click(function () {
            jmdf.minForm("areaJieSuanForm?contractId=${(contract.id)!}", "860px", "500px");
        });
        //设置剩余面积是否结算
        $(".setArea").click(function () {
            jmdf.view("../adjustArea/form?contractId=${(contract.id)!}", 90);
        });
        //打印签认表
        $(".chooseResultPrint").click(function () {
            $.ajax({//选房顺序号非重验证
                url: 'getIsMustBigHouse',
                type: 'post',
                data: {
                    contractId: '${(contract.id)!}'
                },
                async: false,
                success: function (data) {
                    isMustBigHouse = data;
                }
            });

            if (isMustBigHouse == true) {
                jmdf.print("chooseResultPrint?contractId=${(contract.id)!}", "50");
            } else {
                alert("请先仔细核对该户选房方案，若无误，请联系技术支持取消选房限制！");
            }
        });

        //设置签认状态
        $(".chooseHouseStatus").click(function () {
            var msg = '${contract.financeCheckStatus}' == 1 ? "已签认" : "未签认";
            layer.open({
                title: false,
                shade: 0.5,
                content: "确认设置为" + msg + "吗？设置后房源不可修改！",
                btn: ['确定', '取消'],
                closeBtn: 0,
                btnAlign: 'c'
                ,
                yes: function (index) {
                    $.get("chooseHouseStatus", {
                        contractId: '${(contract.id)!}',
                        _time: new Date().getTime()
                    }, function (data) {
                        if (data.code == "0001") {//成功
                            parent.loadData();
                            layer.msg(data.message, {anim: 0, icon: 1, time: 1000}, function () {
                                location.reload();
                            });
                        } else {//失败
                            layer.msg(data.message, {anim: 6, icon: 2, time: 3000});
                        }
                        layer.close(index);
                    });
                }
            });
        })
    });
</script>
</body>
</html>